package com.jic.market.impl;

import java.lang.Long;
import java.util.List;

import com.jic.market.entity.LotteryDrawLimit;
import com.jic.market.mapper.LotteryDrawLimitMapper;
import com.jic.market.service.LotteryDrawLimitService;
import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 抽奖活动用户限制记录表
 * @author : 
 * @email : 
 * @since : 2020-03-03 03:06:12
 * @version : v1.0.0
 */
@Service
public class LotteryDrawLimitServiceImpl implements LotteryDrawLimitService{

    @Autowired
    private LotteryDrawLimitMapper lotteryDrawLimitMapper;

    @Override
    public long insert(LotteryDrawLimit lotteryDrawLimit) {
        long flag = lotteryDrawLimitMapper.insert(lotteryDrawLimit);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return lotteryDrawLimitMapper.delete(id);
    }

    @Override
    public long update(LotteryDrawLimit lotteryDrawLimit) {
        return lotteryDrawLimitMapper.update(lotteryDrawLimit);
    }

    @Override
    public LotteryDrawLimit queryByPrimaryKey(Long id){
        return lotteryDrawLimitMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<LotteryDrawLimit> query(LotteryDrawLimit lotteryDrawLimit){
        return lotteryDrawLimitMapper.query(lotteryDrawLimit);
    }

    @Override
    public PageResult<LotteryDrawLimit> queryPage(LotteryDrawLimit lotteryDrawLimit, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<LotteryDrawLimit> list = lotteryDrawLimitMapper.queryPage(startIndex, pageQuery.getLimit(), lotteryDrawLimit);
        long count = lotteryDrawLimitMapper.queryPageCount(lotteryDrawLimit);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}